﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class my_db1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ctpDataContext db = new ctpDataContext();


        var ctsa = from p1 in db.ct_s_pics
                  select p1;

        foreach (ct_s_pic c in ctsa)
        {
            try
            {
                c.ct_no = db.ct_s_profiles.Single(p => p.valid == true && p.no == c.ct_s_no).ct_no;
            }
            catch
            {
                c.ct_no = -1;
            }
        }

        db.SubmitChanges();






        var cts = from p1 in db.ct_s_intros
              select p1;

        foreach (ct_s_intro c in cts)
        {
            try
            {
                c.ct_no = db.ct_s_profiles.Single(p => p.valid == true && p.no == c.ct_s_no).ct_no;
            }
            catch
            {
                c.ct_no = -1;
            }
        }

        db.SubmitChanges();

    }
    

}
